import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
import { WechatService } from './wechat.service';
import { ResponseSuccess } from '../common/response/response.interface';

// 定义请求体的数据结构
class SignatureDto {
  url: string;
}

@Controller('wechat')
export class WechatController {
  constructor(private readonly wechatService: WechatService) {}

  @Post('signature')
  @HttpCode(HttpStatus.OK)
  async getSignature(@Body() signatureDto: SignatureDto): Promise<ResponseSuccess> {
    const config = await this.wechatService.getJssdkConfig(signatureDto.url);
    return new ResponseSuccess(config, '获取签名成功');
  }
} 